package cn.edu.ujn.park.service;

import cn.edu.ujn.park.dao.Rate;
import cn.edu.ujn.park.dao.RateMapper;
import cn.edu.ujn.park.dao.User;
import cn.edu.ujn.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RateServiceImpl implements IRateService{
    @Autowired
    private RateMapper rateMapper;
    @Override
    public void insert(Rate rate) {
        rateMapper.insert(rate);
    }

    @Override
    public void updateByPrimaryKey(Rate rate) {
        rateMapper.updateByPrimaryKey(rate);
    }

    @Override
    public void deleteByPrimaryKey(Integer rateId) {
rateMapper.deleteByPrimaryKey(rateId);
    }

    @Override
    public Rate getRateById(Integer rateId) {
        return rateMapper.selectByPrimaryKey(rateId);
    }

    @Override
    public Page<Rate> selectAll(Rate rate) {
        Page<Rate> page = new Page<>();
        List<Rate> list = rateMapper.selectAll(rate);
        Integer count=rateMapper.selectCount(rate);


        page.setPage(rate.getStart());
        page.setRows(list);
        page.setSize(rate.getRows());
        page.setTotal(count);

        return page;
    }

    @Override
    public String selectRateName(Integer rateId) {
        return null;
    }
}
